Skip to main content

All Questions

5votes
1answer
104views

Is there a Numpy method or function to split an array of uint64 into two arrays of uint32

Say I have an array as follows: arr = np.asarray([1, 2, 3, 4294967296, 100], dtype=np.uint64) I now want two arrays, one array with the lower 32 bits of every element, and one with the upper 32 bits ...
lrdewaal's user avatar
1vote
0answers
99views

Why is dividing a uint8 numpy array by a float32 faster than explicit type conversion?

I am working with some image data so the images are represented as numpy arrays with shape (1404, 1404, 3). The image is of type np.uint8 (it has RGB values from 0 to 255) I am wondering about the ...
AntonioMacaronio's user avatar
1vote
2answers
117views

Numba njit making function call involving long expressions extremely slow

I am writing a finite volume code to solve the inviscid, compressible Euler equations. As a part of this, I am performing what is known as the Cauchy-Kovalevskaya process. A code snippet is given ...
Siddharth Yajaman's user avatar
3votes
1answer
242views

Why does NumPy drastically slow down when I *decrease* the size of an array?

I have a 2D NumPy array, where the entries are random floats clustered tightly around 1.0, e.g. 1.015, 0.989, etc. The number of rows is n_rows = 10^4, and the number of columns is 2^13: n_rows = 10**...
Mr. Jefferson's Ghost's user avatar
1vote
1answer
132views

How to efficiently slice numpy arrays? (Finite difference method)

I am trying to use the finite difference method with NumPy arrays, but the slicing is incredibly slow. It's not viable to use lists as I am applying math operations. Using matlab, equivalent code is ...
THATS MY QUANT MY QUANTITATIVE's user avatar
0votes
2answers
65views

Python Numpy: Is there a faster way to modify multiple arrays of the same shape when the changes are the same?

I have multiple numpy arrays that are all the same shape. I have two masks that are also that same shape. Right now I'm changing each array one at a time. Is there a faster way to do this? This is a ...
postsabrent's user avatar
0votes
2answers
59views

Unzigzag an array into a matrix

I have a 1D array which is in fact a 2D matrix sampled this way: ↓-------<------S <- start >------->------↓ ↓-------<------< >------->------E <- end For example B = 1 ...
Basj's user avatar
  • 46.7k
0votes
0answers
42views

speed up numpy array averaging by block

Is it possible to speed up the following code? Here xyz is the Nx3 coordinate array of all the atoms in many identical molecules. mol_atom_indices can be thought of as list of lists. Each list ...
nos's user avatar
  • 21k
4votes
1answer
1kviews

NumPy filling values inside given bounding box coordinates for a large array

I have a very large 3d array large = np.zeros((2000, 1500, 700)) Actually, large is an image but for each coordinate, it has 700 values. Also, I have 400 bounding boxes. Bounding boxes do not have a ...
Shadovx's user avatar
3votes
1answer
2kviews

numpy argsort slow performance

My sincere apologies, in advance if this question seems quite basic. Given: >>> import numpy as np >>> import time >>> A = np.random.rand( int(1e5), int(5e4) ) # large numpy ...
doplano's user avatar
  • 1,601
-3votes
1answer
1kviews

Are numpy arrays faster than lists? [closed]

I am new to using python and numpy arrays.While i was going through the notes online,saw a mention about how ndarray's are faster than lists.. "NumPy arrays are stored at one continuous place in ...
Shyam's user avatar
0votes
3answers
437views

Most efficient way to calculate the average of a function between pairs for each element in Python?

Problem: I have M objects sampled at different frames and I want to calculate the distance between pairs at each frame. I store the distances as a multidimensional array xij with three axis, where ...
Puco4's user avatar
0votes
0answers
133views

Combine the arrays in these datasets of a HDF5 file and finally get a 2D

I have an HDF5 file and it contains 500 datasets (named A000, A001, A002, A003 .... A499) and each dataset contains arrays of (200, 5400) sizes. I want to combine the arrays in these datasets and ...
mehmet_kacmaz_03's user avatar
1vote
0answers
22views

numpy arrays vs core python lists [duplicate]

I've heard numpy is much faster than core python lists in case of manipulation speed . but when I ran these pieces of code I got oposite. Can anyone explain to me how this happens ? def pure_py_list():...
davood asgharzadeh's user avatar
2votes
0answers
872views

How to create bump map using as little RAM as possible?

I am working with Python and NumPy. I have an image: Its heightmap: I want to combine them to create a bump map like: I need to use as little RAM as possible. The formula is: newColor = oldColor+(...
Gabriele Maurina's user avatar

153050per page
close